<?php

/* Owner Name */
$name = $json['owner_name'];

/* Last edit date */
$date = strftime('%H:%M %a, %d %h %Y', $json['updated']);

/* Post image */
if ( empty( $json['img'] ) ) {
    $teaser_img = '';
    $rounded = 'rounded';
} else {
    $teaser_img = "<img src='{$json['url']}/{$json['img']}'>";
    $rounded = '';
}

/* Owner Avatar */
if ( $json['owner_node'] === $_SERVER['SERVER_NAME'] && !empty( $config['avatar'] ) && file_exists( $soc['dir'].$config['avatar'] ) ) {
    $avatar = $config['avatar'];
} else {
    $avatar = '/img/std/anonymous.svg';
}

/* Control Buttons */
$buttons = '';
if ( is_owner() ) {
    $buttons .= "<div class=edit data-hide='{$json['id']}'>hide</div>";
    $buttons .= "<div class=edit data-edit='{$json['url']}'>edit</div>";
    $buttons .= "<div class=del data-del='{$json['url']}'>X</div>";
}

if ( $json['public'] === 'true' ) {
    $class = "class=teaser";
} else {
    $class = 'class="teaser private"';
}

echo <<<EOT
<div {$class} data-teaser>
    <div class=teaser-img>{$teaser_img}</div>
    <div class='teaser-panel {$rounded}' data-panel>
        <span class=name>{$name}</span>
        <span class=date>{$date}</span>
        {$buttons}
    </div>
    <div class=teaser-ava><img src="{$avatar}"></div>
    <div class=teaser-title>
        <h2><a data-post-link href='{$json['url']}'>{$json['title']}</a></h2>
    </div>
    <div class=teaser-text>{$json['html']}</div>
</div>
EOT;
?>